#include "base.h"

std::vector<std::string> split(std::string str,std::string delimiter) {
    while (str[str.size() - 1] == '\r' || str[str.size() - 1] == '\n' || str[str.size() - 1] == '\t' || str[str.size() - 1] == ' ') {
        str = str.substr(0, str.size() - 1);
    }
    std::string::size_type pos;
    std::vector<std::string> split_vector;
    str += delimiter;
    int size = str.size();
    for(int i = 0; i < size; i++) {
        pos = str.find(delimiter, i);
        if(int(pos) < size) {
            std::string s = str.substr(i, pos - i);
            split_vector.push_back(s);
            i = pos + delimiter.size() - 1;
        }
    }
    return split_vector;
}